//
//  MControlDeviceTypeCell.m
//  Mask
//
//  Created by 郭子一 on 2020/10/4.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MControlDeviceTypeCell.h"

@interface MControlDeviceTypeCell ()
@property (nonatomic, strong) UIImageView *img;
@property (nonatomic, strong) UILabel *modeLabel; // 模式
@property (nonatomic, strong) UILabel *nowModeLabel; // 当前模式
@property (nonatomic, strong) UILabel *modeExplainLabel; // 模式说明



@end

@implementation MControlDeviceTypeCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = UIColor.clearColor;
        [self makeUI];
    }
    return self;
}

///private
- (void)makeUI {
    
    UIView *view = [[UIView alloc] init];
    view.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
    view.layer.cornerRadius = 10;
    view.layer.shadowColor = [UIColor colorWithRed:93/255.0 green:102/255.0 blue:147/255.0 alpha:0.15].CGColor;
    view.layer.shadowOffset = CGSizeMake(0,2);
    view.layer.shadowOpacity = 1;
    view.layer.shadowRadius = 8;
//    view.layer.masksToBounds = YES;
    [self.contentView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.bottom.offset(-10);
//        make.edges.offset(0);
    }];
    
    self.img = [[UIImageView alloc] init];
    self.img.backgroundColor = UIColor.cyanColor;
    [view addSubview:self.img];
    [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(25);
        make.left.offset(20);
        make.width.height.mas_equalTo(32);
    }];
    
    self.modeLabel = [[UILabel alloc] init];
    self.modeLabel.text = @"运动模式";
    self.modeLabel.font = JSS_FONT_4;
    self.modeLabel.textColor = RGB_VALUE(0x2D3033);
    [view addSubview:self.modeLabel];
    [self.modeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.img);
        make.left.equalTo(self.img.mas_right).offset(13);
        make.height.mas_equalTo(20);
        make.right.offset(-110);
    }];
    
    self.nowModeLabel = [[UILabel alloc] init];
    self.nowModeLabel.text = @"当前工作模式";
    self.nowModeLabel.font = JSS_FONT_0;
    self.nowModeLabel.textColor = RGB_VALUE(0xFFFFFF);
    self.nowModeLabel.textAlignment = NSTextAlignmentCenter;
    self.nowModeLabel.backgroundColor = RGB_VALUE(0x0191FE);
    // gradient
//    CAGradientLayer *gl = [CAGradientLayer layer];
//    gl.frame = CGRectMake(0,0,94,22);
//    gl.startPoint = CGPointMake(0, 0.5);
//    gl.endPoint = CGPointMake(1, 0.5);
//    gl.colors = @[(__bridge id)[UIColor colorWithRed:0/255.0 green:195/255.0 blue:254/255.0 alpha:0.9].CGColor, (__bridge id)[UIColor colorWithRed:1/255.0 green:145/255.0 blue:254/255.0 alpha:0.9].CGColor];
//    gl.locations = @[@(0), @(1.0f)];
////    gl.zPosition = -10;
//    [self.nowModeLabel.layer addSublayer:gl];
    self.nowModeLabel.layer.cornerRadius = 12;
    self.nowModeLabel.layer.masksToBounds = YES;
    [view addSubview:self.nowModeLabel];
    [self.nowModeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.img);
        make.right.offset(-10);
        make.height.mas_equalTo(22);
        make.width.mas_equalTo(94);
    }];
    
    self.modeExplainLabel = [[UILabel alloc] init];
    self.modeExplainLabel.numberOfLines = 0;
    self.modeExplainLabel.text = @"此工作模式下，1中的3个参数都不可调节，为固定值：呼吸跟随开、压力为0、助力为100：";
    self.modeExplainLabel.font = JSS_FONT_0;
    self.modeExplainLabel.textColor = RGB_VALUE(0x879099);
    [view addSubview:self.modeExplainLabel];
    [self.modeExplainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.img.mas_bottom).offset(16);
        make.left.offset(20);
        make.bottom.mas_equalTo(-10);
        make.right.offset(-20);
    }];
}

@end
